#include <windows.h>
#include "HexDump.h"
#include "Resource.h"
#include "MainWnd.h"


HWND CreateMainWnd(HINSTANCE instance)
{
	static const TCHAR appName[] = TEXT("Hex Dump");

	HMENU    menu;
	WNDCLASS wndclass;


	wndclass.style         = CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc   = MainWndProc;
	wndclass.cbClsExtra    = 0;
	wndclass.cbWndExtra    = 0;
	wndclass.hInstance     = instance;
	wndclass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
	wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
	wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
	wndclass.lpszMenuName  = NULL;
	wndclass.lpszClassName = appName;

	if(!RegisterClass(&wndclass))
	{
		MessageBox(NULL, TEXT("This program requires Windows NT"),
			appName, MB_ICONERROR);
		return 0;
	}

	menu = LoadMenu(instance, MAKEINTRESOURCE(IDR_MAIN_MENU));

	return CreateWindow
		(
			appName,             // Window class name
			appName,             // Window caption
			WS_OVERLAPPEDWINDOW, // Window style
			CW_USEDEFAULT,       // Initial x position
			CW_USEDEFAULT,       // Initial y position
			CW_USEDEFAULT,       // Initial x size
			CW_USEDEFAULT,       // Initial y size
			NULL,                // Parent window handle
			menu,                // Window menu handle
			instance,            // Program instance handle
			NULL                 // Creation parameters
		);
}